package net.sxnic.item.action;

import net.sxinfo.core.dao.Page;
import net.sxnic.item.mdata.action.MdataAction;
import net.sxnic.ugr.security.AuthorizationManager;
import net.sxnic.ugr.user.User;
import net.sxnic.ugr.user.UserManager;

import org.springframework.beans.factory.annotation.Autowired;

@SuppressWarnings("serial")
public class ApproverDelete extends MdataAction {
	
	User user;
	@Autowired
	UserManager userManager;
	@Autowired
	AuthorizationManager authorizationManager;
	private String userId;
	
	public String execute() throws Exception {
		
		user = userManager.get(userId);
		if(user==null)
		{
			return INPUT;
		}
		//禁用操作
		if(user.getEnabled())
		{
			user.setEnabled(false);
			userManager.update(user);
			msg = "jinyongSuccess";
			return SUCCESS;
		}
		//启用操作
		if(!user.getEnabled())
		{
			user.setEnabled(true);
			userManager.update(user);
			msg = "qiyongSuccess";
			return SUCCESS;
		}
		return SUCCESS;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
}
